#include "bits/stdc++.h"

using namespace std;

const int N = 1e5 + 10;
int n;
int a[N];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    int res = 0;
    for (int i = 0; i < n; i += 2)
    {
        res += abs(a[i] - a[i + 1]);
    }
    cout << res << endl;
    return 0;
} 